import axios from 'axios'
import store from 'store'
import config from '../../config'

export const uploadFile = (file) => {
    return new Promise((resolve, reject) => {
        const formData = new FormData()
        formData.append('file', file)
        axios.post(config.server + 'upload', formData, {
            headers: {
                'Content-Type': 'multipart/form-data',
                'token': store.get('token')
            },
        })
            .then(response => {
                resolve(response.data.data); // 处理响应数据
            })
            .catch(error => {
                reject(error); // 处理错误信息
            });
    })
}